Technical Q&A JAVA04
Using .zip and .jar Files With Applets


Q: Normally, when you run an applet, you have several class files, and an html file that calls your main class like this:

<APPLET CODE="MyMainClass.class" WIDTH=200 HEIGHT=200>< /APPLET>

What if I want to have all my classes in a .jar or .zip file? If this is possible, what html code do I now use to call the applet?

A: To load your applet classes from a .jar or .zip file, you need to use the " ARCHIVE" tag in your applet statement. An example of this would be:

<APPLET ARCHIVE="classes.jar" CODE="MyMainClass.class" WIDTH=200 HEIGHT=200></APPLET>

where "classes.jar" would be the name of your .jar or .zip file containing the "MyMainClass.class" and its supporting class files.

[Feb 22 1999]


Developer Documentation | Technical Notes | Development Kits | Sample Code